package com.api.devices.domain.vo;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.api.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Date;
import java.util.List;
import java.util.Set;

@Getter
@Setter
public class ElementVo extends BaseEntity {
    /**
     * 设备所属plc ID
     */
    private Long ipcId;
    /**
     *
     */
    private String ipcName;
    /**
     * 设备所属产线ID
     */
    private Long lineId;
    /**
     * 产线名称
     */
    private String lineName;
    /**
     * 设备ID
     */
    private Long robotId;
    /**
     * 设备名称
     */
    private String robotName;

    private Long elementId;
    private String elementName;
    private JSONObject elementNameLocales;
    private String strElementNameLocales;

    private String elementCode;
    /**
     * 设备传感器卡号 第几个卡号
     */
    private int ipcSlot;
    private Set<String> datColSet;
    private String strDatColSet;

    private List<Double> score;
    private String strScore;
    private Double ratio;
    /**
     * 描述
     */
    private String remark;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 创建人
     */
    private String createBy;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 更新人
     */
    private String updateBy;
    /**
     * 选择第N页
     */
    private int pageNum;
    /**
     * 每页显示量
     */
    private int pageSize;

    private String appLang;

    public void setElementNameLocales(JSONObject elementNameLocales) {
        this.elementNameLocales = elementNameLocales;
        if (ObjectUtils.isNotEmpty(elementNameLocales))
            this.strElementNameLocales = elementNameLocales.toString();
    }


    public void setStrDatColSet() {
        this.strDatColSet = datColSet.toString();
    }

    public String getStrDatColSet() {
        if (this.datColSet == null) return null;
        return datColSet.toString();
    }

    public void initControl(String username, String appLang) {
        this.appLang = appLang;
        this.updateBy = username;
        this.createBy = username;
    }

    public void setScore(List<Double> score) {
        this.strScore = score.toString();
        this.score = score;
    }

    public String getScore() {
        return this.score.toString();
    }
}
